import CompanyNameService from '../../services/companyName/CompanyNameService';
export default {

  namespace: 'public',

  state: {
    AllCompanyName  : [], // 项目公司名称集合下拉选
    user: '',
  },

  effects: {
    *saveUser({payload}, {put}) {
      yield put({type: 'save', payload})
    },
    // 获取所有项目名称,以及对应的id,code,
    *getAllProjectInfo({payload}, {call, put}) {
      let ret = yield call(CompanyNameService.AllCompanyName);
      yield put({type: 'save', payload: {AllCompanyName: ret}});
    },
  },
  reducers: {
    save(state, {payload}) {
      return {...state, ...payload};
    }
  },
  subscriptions: {
    setup({dispatch, history}) {
      return history.listen(({pathname, query}) => {
          dispatch({type: 'getAllProjectInfo'});
      });
    },
  },
};
